<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="../../lib/html5shiv.js?rev=@@hash"></script>
    <script type="text/javascript" src="../../lib/respond.min.js?rev=@@hash"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" type="text/css" href="../../ht-css/Project.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="../../lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>账号信息编辑</title>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 客户管理
    <span class="c-gray en">&gt;</span> 合同管理
    <span class="c-gray en">&gt;</span> 账号信息编辑
</nav>
<article class="page-container">
    <div class="mt-20 pl-10"><strong>账号池</strong></div>
    <table class="table table-border table-bordered  table-bg table-sort mt-10 re-list3-nav" id="datatable">
        <thead class="text-c">
        <tr>
            <th>账号</th>
            <th>认证手机</th>
            <th>状态 </th>
            <th>创建时间 </th>
            <th>创建人</th>
        </tr>
        <tr style="background-color: #FFF1E3; " id="accountTr">
            <td  colspan="6">
                <form  id="zomg-add"  method="post">
                    <input type="text"   name="loginAccount"  style="width: 177px;height: 36px;font-size: 16px;float: left;border-radius:14px;border:2px solid #000;"  placeholder="请输入账号" onkeyup="value=value.replace(/[^\w\.\/]/ig,'')"type="text">

                    <input type="hidden" name="belongCustomerCode" >
                    <input type="hidden" name="belongCustomerId" >
                    <input type="hidden" name="createUser" >
                    <div style="float: left;margin-left: 44px;margin-top: 10px;">
                        <label><input name="" type="button"  class="btn radius size-S c-blue total" value="&nbsp;确&nbsp;&nbsp;认&nbsp;" id="addAccount"></label>
                    </div>

                </form>
            </td>
        </tr>
        </thead>
        <tbody class="shun">
        </tbody>

    </table>
    <div class="mt-40"></div>
    <div class="dataTables_wrapper goods_fanye clearfix mt-5">
        <div class="f-r pageturning M-box3"></div>
    </div>

    <div class="mt-30 pl-10"><strong>建立关联</strong></div>
    <div class="mt-10 bg-1 re-list-box2" style="height:486px">
        <table class="table table-border table-bordered table-hover table-bg table-sort" id="datatables">
            <thead>
            <tr class="text-c">
                <th width="50">结算账号</th>
                <th width="50">下单账号</th>
                <th width="50">审批账号</th>
                <th width="50">是否关联</th>
                <th width="60">操作</th>
            </tr>
            <tr class="text-c">
                <th width="50">
                    <select class="select radius" name="brandclass" size="1" style="height: 30px;" id="zong_lsit">
                        <script id="zong_bob" type="text/x-dot-template">
                            <option selected disabled="disabled" >请输入结算账号</option>
                            <!--{{if( it && it.length>0 ){ }}
                            {{ for(var i=0; i< it.length; i++) { }}
                            <option value="{{=it[i].login_account}}">{{=it[i].login_account}}</option>
                            {{ } }}
                            {{ }else{ }}
                            <option>没有数据</option>
                            {{ } }}-->
                        </script>
                    </select>
                </th>
                <!--<th width="50">
                    <input type="text" class="input-text radius"  id="zong_fin" placeholder="请输入授信额度" onkeyup="if(this.value.length==0){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" maxlength="8">
                </th>-->
                <th width="50">
                    <select class="select radius" name="brandclass" size="1" style="height: 30px;" id="fen_lsit">
                        <script id="fen_bob" type="text/x-dot-template">
                            <option selected disabled="disabled">请输入下单账号</option>

                            <!--<option value="{{=it[i].login_account}}">{{=it[i].login_account}}</option>
                            {{ } }}
                            {{ }else{ }}
                            <option>没有数据</option>
                            {{ } }}-->
                        </script>
                    </select>
                </th>
                <!--<th width="50">
                    <input type="text" class="input-text radius"  id="fen_fin"   placeholder="请输入授信额度" onkeyup="if(this.value.length==0){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" maxlength="8">
                </th>-->
                <th width="50">
                    <select class="select radius" name="brandclass" size="1" style="height: 30px;" id="shen_list">
                        <script id="shen_bob" type="text/x-dot-template">
                            <option selected disabled="disabled">请输入审批账号</option>
                            <!-- {{if( it && it.length>0 ){ }}
                             {{ for(var i=0; i< it.length; i++) { }}
                             <option value="{{=it[i].login_account}}">{{=it[i].login_account}}</option>
                             {{ } }}
                             {{ }else{ }}
                             <option>没有数据</option>
                             {{ } }}-->
                        </script>
                    </select>
                </th>
                <th width="50">待关联</th>
                <th width="60" id="jianli"><a>建立关联</a></th>
            </tr>
            </thead>
            <tbody class="text-c" id="guanl_list">
            <script id="guanl_bob" type="text/x-dot-template">
                {{if( it && it.length>0 ){ }}
                {{ for(var i=0; i< it.length; i++) { }}
                <tr>
                    <th>{{=it[i].total_account}}</th>
                    <!--<th>{{=it[i].total_limit}}</th>-->
                    {{if(it[i].account_state == "1" ){ }}
                    <th>{{=it[i].sub_account}}<input type="submit" onclick="Close_number('{{=it[i].total_sub_audit_account_id}}',0,'确认关闭账号')" class="btn radius size-MINI c-blue total ml-10" value="&nbsp;关&nbsp;&nbsp;闭&nbsp;"></th>
                    {{ }else{ }}
                    <th class="">{{=it[i].sub_account}}<input type="submit" onclick="Close_number('{{=it[i].total_sub_audit_account_id}}',1,'确认开启账号')" class="btn radius size-MINI c-blue total ml-10" value="&nbsp;开&nbsp;&nbsp;启&nbsp;"></th>
                    {{ } }}
                    <!--<th>{{=it[i].sub_limit}}</th>-->
                    {{if(it[i].audit_account == null ){ }}
                    <th>空</th>
                    {{ }else{ }}
                    <th>{{=it[i].audit_account}}</th>
                    {{ } }}
                    {{if(it[i].relation_type == "1" ){ }}
                    <th>已关联</th>
                    <th><a class="c-red" onclick="Relieve_relationship('{{=it[i].total_sub_audit_account_id}}',0,'确认解除关联')">解除关联</a></th>
                    {{ }else{ }}
                    <th>未关联</th>
                    <th><a onclick="Relieve_relationship('{{=it[i].total_sub_audit_account_id}}',1,'确认建立关联')">建立关联</a></th>
                    {{ } }}
                </tr>
                {{ } }}
                {{ }else{ }}
                <th>没有数据</th>
                {{ } }}
            </script>
            </tbody>
        </table>
    </div>
    <div class="text-c mt-20">
        <input id="bottm" type="submit" onclick="cancel()" type="button" class="btn btn-secondary radius size-S botter " value="&nbsp;提&nbsp;&nbsp;交&nbsp;">
        <input name="" type="reset" onclick="cancel()" class="btn radius size-S botter ml-10" value="&nbsp;取&nbsp;&nbsp;消&nbsp;">
    </div>
    <div class="mt-20 text-c mb-20">
        鑫方盛电子商务股份有限公司提供支持
    </div>
</article>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../../lib/jquery/1.9.1/jquery.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/layer/2.4/layer.js?rev=@@hash"></script>
<script type="text/javascript" src="../../static/h-ui/js/H-ui.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../static/h-ui.admin/js/H-ui.admin.js?rev=@@hash"></script> <!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="../../lib/My97DatePicker/4.8/WdatePicker.js?rev=@@hash"></script>
<!--引入分页-->
<link rel="stylesheet" href="../../lib/pagination/pagination.css">
<script src="../../lib/pagination/jquery.pagination.js?rev=@@hash"></script>
<!--表单验证-->
<script type="text/javascript" src="../../lib/jquery.validation/1.14.0/jquery.validate.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/jquery.validation/1.14.0/validate-methods.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/jquery.validation/1.14.0/messages_zh.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/datatables/1.10.0/jquery.dataTables.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../lib/laypage/1.2/laypage.js?rev=@@hash"></script>
<script src="../../ht-js/contract/jquery-form.js?rev=@@hash"></script>
<script src="../../ht-js/frame/doT.min.js?rev=@@hash"></script>
<script src="../../ht-js/public.js?rev=@@hash"></script>
<!--验证token-->
<script src="../../ht-js/verifyToken.js?rev=@@hash"></script>
<script src="../../ht-js/contract/oods_pool.js?rev=@@hash"></script>
<script>
    $(function(){

        //获取当前操作人
        var quzhi=JSON.parse(web.readCookie("loginData"));
        var nowUser = quzhi.user.name;
        $("input[name='createUser']").val(nowUser);
        //获取customerCode
        var customerCode = getQueryString('id');
        $("input[name='belongCustomerCode']").val(customerCode);
        //获取customdeId
        var customerId = getQueryString('customerId');
        $("input[name='belongCustomerId']").val(customerId);

        findAccountByCustomerCode();


    });


    //添加账户
    $("#addAccount").click(function () {
        //防止表单重复提交
        $("#addAccount").attr("disabled",true);
        var loginAccont = $("input[name='loginAccount']").val();
        if (null != loginAccont && "" != loginAccont) {
            $('#zomg-add').ajaxSubmit({
                url:'https://'+ window.location.host +'/api/admin/acontract/account/addCustomerAccount.jhtml',
                type:"post",  //提交方式
                success:function (data) {
                    if (data.errorCode == 0){
                        layer.msg('添加成功!', {icon: 6,time:1000});
                        $("#addAccount").attr("disabled",false);
                        //清空账号
                        $("input[name='loginAccount']").val("");
                        $("input[name='enable_order']").attr("checked",false);
                        $("input[name='enable_order']").val(20);
                        $("input[name='enable_audit']").attr("checked",false);
                        $("input[name='enable_audit']").val(20);
                        $("input[name='enable_settle']").attr("checked",false);
                        $("input[name='enable_settle']").val(20);
                        //清空下拉框
                        $("#fen_lsit").html("");
                        $("#shen_list").html("");
                        $("#zong_lsit").html("");
                        findAccountByCustomerCode();
                        zfsdata()
                    }else{
                        layer.msg("添加失败！原因("+data.errorMessage+")", {icon:5,time:2000});
                        $("#addAccount").attr("disabled",false);
                    }
                }
            })
        }else {
            layer.msg('账号不能为空!', {icon: 5,time:2000});
            $("#addAccount").attr("disabled",false);
        }


    })

    function findAccountByCustomerCode() {
        //获取customerCode
        var customerCode = getQueryString('id');
        //查询该客户的所有账号信息
        $.post('https://'+ window.location.host +'/api/admin/amembership/findAccountByCustomerCode.jhtml',{customerCode:customerCode},function (data) {

            //下单账号
            var account = data.account;
            if (null != account) {
                $("#fen_lsit").append("<option selected disabled='disabled'>请输入下单账号</option>");
                //循环填充所有的下单账号
                $.each(account,function(idx, obj) {
                    $("#fen_lsit").append("<option value='"+obj.login_account+"'>"+obj.login_account+"</option> ")
                    $("#fen_lsit").append("<input type='hidden' id='sub"+obj.login_account+"' value='"+obj.member_id+"' name='memberId'> ")
                });
            }else{
                $("#fen_lsit").append("<option>没有数据</option>")
            }

            //审批账号
            if (null != account) {
                $("#shen_list").append("<option selected disabled='disabled'>请输入审批账号</option>");
                //循环填充所有的下单账号
                $.each(account,function(idx, obj) {
                    $("#shen_list").append("<option value='"+obj.login_account+"'>"+obj.login_account+"</option> ")
                    $("#shen_list").append("<input type='hidden' id='audit"+obj.login_account+"' value='"+obj.member_id+"' name='memberId'> ")
                });
            }else{
                $("#shen_list").append("<option>没有数据</option>")
            }

            //结算账号
            if (null != account) {
                $("#zong_lsit").append("<option selected disabled='disabled'>请输入结算账号</option>");
                //循环填充所有的下单账号
                $.each(account,function(idx, obj) {
                    $("#zong_lsit").append("<option value='"+obj.login_account+"'>"+obj.login_account+"</option>")
                    $("#zong_lsit").append("<input type='hidden' id='total"+obj.login_account+"' value='"+obj.member_id+"' name='memberId'> ")
                });
            }else{
                $("#zong_lsit").append("<option>没有数据</option>")
            }
        })
    }
</script>

</body>
</html>